package com.kele.test.rabbitmq.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("producer")
public class ProducerController {


    @Autowired
    RabbitTemplate rabbitTemplate;

    @PostMapping("test1")
    public String testSendMsg(@RequestBody Map map){
        rabbitTemplate.convertAndSend("","A1",map);
        return "Success";
    }

    @PostMapping("test2")
    public String testSendMsg2(@RequestBody Map map){
        rabbitTemplate.convertAndSend("EX1","1905A",map);
        return "Success";
    }

    @PostMapping("testPeak")
    public String testSendPeak(){

        for(Integer i=1;i<=1000;i++){
            rabbitTemplate.convertAndSend("","A1",i.toString());
        }
        return "Success";
    }
}
